<template>
	<div class="main">
        <MyHeader title="购物车案例" bgc="gold" color="lime"></MyHeader>
				<MyGoods v-for="item in list" :key="item.goods_id" :obj="item"></MyGoods>
				<MyFooter :arr="list"></MyFooter>
	</div>
</template>

<script>
  import MyHeader from './components/MyHeader.vue'
  import MyGoods from './components/MyGoods.vue'
  import MyFooter from './components/MyFooter.vue'

// 引入第三方包
	import 'bootstrap/dist/css/bootstrap.css'
	import axios from 'axios'
	

	// 获取-购物车列表接口  GET  https://applet-base-api-t.itheima.net/api/cart

	export default {
		data() {
			return {
				list: [] // 商品所有数据
			}
		},

		created () {
			  this.getList()
		},

		methods: {
			async getList(){
         const {data:res} =  await axios.get('https://applet-base-api-t.itheima.net/api/cart')
				//  console.log(res);

				 this.list = res.list   //将发送请求获得的数据 存储至 list 中
			 }
		},

		components: {
			  MyHeader,
				MyGoods,
				MyFooter
		}
	}
</script>

<style scoped>
	.main {
		padding-top: 45px;
		padding-bottom: 50px;
	}
</style>
